package fr.demo.list;

import android.app.ActivityGroup;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;


/**
 * How to use the Tab Layout navigation :
 * 	 1) Define 1 activity per tab
 *   2) First create XML file containing the TabHost definition :
 *	 3) Your activity must extend the ActivityGroup :
 * The Activity group allows to manage your group of activity and
 * avoiding of the managing activity creation/destruction
 * 	 4) set the Content view
 * 	 5) SETUP your TabHost (don't forget)
 *   6) Create new Tab per Activity, with the well Intent Object for
 * start your activity
 * @author hong
 *
 */
public class ListDemo extends ActivityGroup {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /* Set the content view with your XML GUI */
        setContentView(R.layout.main);
        
        /* Local variable */
        Resources res = getResources();
        TabHost.TabSpec spec;
        Intent intent;
        
        /* Get the TabHost manager views and initiaze it */
        TabHost tabHost = (TabHost) this.findViewById(R.id.tabhost);
        tabHost.setup(getLocalActivityManager());
        
        

        /* Creation of a new TAB :
         *  1) Create the Intent
         *  2) Create the TAB
         *  3) Set the indicator (icon)
         *  4) Set the intent message
         *  5) Add the TAB
         */
        intent = new Intent().setClass(this, SimpleList.class);
        spec = tabHost.newTabSpec("Liste 1");
        spec.setIndicator("Liste 1",res.getDrawable(R.drawable.icone_animation));
        spec.setContent(intent);
        tabHost.addTab(spec);
        
        /* Creation of a new TAB :
         *  1) Create the Intent
         *  2) Create the TAB
         *  3) Set the indicator (icon)
         *  4) Set the intent message
         *  5) Add the TAB
         */
        intent = new Intent().setClass(this, BindingCustomList.class);
        tabHost.setup(getLocalActivityManager());
        spec = tabHost.newTabSpec("Liste 2");
        spec.setIndicator("Liste 2",res.getDrawable(R.drawable.icone_animation));
        spec.setContent(intent);
        tabHost.addTab(spec);
        
        /* Creation of a new TAB :
         *  1) Create the Intent
         *  2) Create the TAB
         *  3) Set the indicator (icon)
         *  4) Set the intent message
         *  5) Add the TAB
         */
        intent = new Intent().setClass(this, DetailCustomList.class);
        tabHost.setup(getLocalActivityManager());
        spec = tabHost.newTabSpec("Liste 3");
        spec.setIndicator("Liste 3",res.getDrawable(R.drawable.icone_animation));
        spec.setContent(intent);
        tabHost.addTab(spec);

    }
}